local hx__chouxiang = fk.CreateSkill {
  name = "hx__chouxiang",

}

hx__chouxiang:addEffect(fk.Death, {
  anim_type = "negative",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self, false, true)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room:getAlivePlayers(), function(p)
      return not p:hasSkill(hx__chouxiang.name) end)
    if #targets == 0 then return end
    local to = room:askToChoosePlayers(player,{
      targets = targets,
      min_num = 1,
      max_num = 1,
      skill_name = hx__chouxiang.name,
      prompt = "#hx__chouxiang-choose",
    })
    if #to > 0 then
      to = to[1]
    else
      to = table.random(targets)
    end
    room:handleAddLoseSkills(to, "hx__haren", nil, true, false)
  end,
})
hx__chouxiang:addEffect(fk.EnterDying, {
  mute = true,
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill(hx__chouxiang.name)
  end,
  on_refresh = function(self, event, target, player, data)
    player:broadcastSkillInvoke(hx__chouxiang.name)
    player.room:notifySkillInvoked(player, hx__chouxiang.name)
  end,
})

return hx__chouxiang